<?php

namespace App\Http\Requests\Backend;

use Illuminate\Foundation\Http\FormRequest;

/**
 * Class StoreAdmin
 * @package App\Http\Requests\Backend
 * 验证管理员
 */
class StoreAdmin extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => 'required|unique:admins,username',
            'password' => 'required'
        ];
    }

    /**
     * @return array
     */
    public function attributes()
    {
        return [
          'username'=> '用户名',
          'password'=> '密码'
        ];
    }

    /**
     * @return array
     */
    public function messages()
    {
        return [
            'username.required'=> '请填写:attribute',
            'username.unique'=> '已存在相同的:attribute',
            'password.required'=> '请填写:attribute'
        ];
    }
}
